#include <avr/io.h>
#include <util/delay.h>



void PORT_init(void)
{
	DDRD = 0xff;
	DDRA = 0xff;
	DDRC = 0xff;
	
	PORTD = 0x00;
	PORTC = 0x00;
	PORTA = 0xff;
}

void set_col(unsigned char col){
	col-=1;
	if(col<8){
	PORTD = 1<<(7-col);
	PORTC = 0;
	}
	else{
	col -= 8;
	PORTC = 1<<(7-col);
	PORTD = 0;
	}
}

void set_line(unsigned char line){
	
	
		PORTA = (1<<line);	
	
}

void simple_scroll(void)
{
	int col,line,col_d,col_c;
	
		for(col=0,col_d=7,col_c=7;col<13;col++){
			if(col<8){
				PORTD = (1<<col_d--);
				PORTC = 0;
				}
				else{
				PORTD = 0;
				PORTC = (1<<(col_c--));
				}
			for(line=0;line<8;line++){
				PORTA = ~(1<<line);
				_delay_ms(10);
			}
		}
}

void mirror_scroll(void)
{
	int col=0;
	PORTA = 0x00;
	while(col<7){
		PORTD = (1<<col);
		PORTC = (1);
		col++;
	}
}


int main(void){
	
	int counter_c,counter_l;
	
	PORT_init();
	PORTA = 0;
	
	counter_c=1;
	counter_l=1;
	while(1){
		set_col(counter_c++);	
		set_line(0b11111101);

		if(counter_c==13)counter_c=1;
    }	
    return 0;
}
